<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0,user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <title>长乐美食城 - 账号注册</title>
    <link rel="stylesheet" href="__PUBLIC__/assets/home/css/register.css">
</head>
<body class="zh_CN">
<div class="wrapper">
    <div class="wrap">
        <div class="layout">
            <div class="n-frame device-frame reg_frame" id="main_container">
                <div class="external_logo_area"><a class="milogo" href="javascript:void(0)"></a></div>
                <div class="title-item t_c">
                    <h4 class="title_big30">注册长乐美食城帐号</h4>
                </div>
                <form>
                    <div class="regbox">
                        <div class="phone_step1">
                            <h4 class="tit_normal">
                                用户昵称：
                            </h4>
                            <div class="listwraps select-regions">
                                <div class="inputbg">
                                    <label class="labelbox">
                                        <input type="text" id="nickname" data-type="PH" placeholder="请输入昵称">
                                    </label>
                                </div>
                            </div>
                            <h4 class="tit_normal">
                                会员编号：
                            </h4>
                            <div class="listwraps select-regions">
                                <div class="inputbg">
                                    <label class="labelbox">
                                        <input type="text" id="customer_no" data-type="PH" value="{{:make_token_code()}}" readonly placeholder="请输入昵称">
                                    </label>
                                </div>
                            </div>
                            <h4 class="tit_normal">
                                上传头像：
                            </h4>
                            <div class="listwraps elect-regions">
                                <div class="inputbg">
                                    <label class="labelbox">
                                        <input type="text" class="new_thumb" placeholder="上传缩略图">
                                    </label>
                                    <div id="upload_one" style="display: none;"></div>
                                    <div id="view_one">
                                        <input type="hidden" name="thumb" id="thumb" value="">
                                        <img src="" class="img-responsive"
                                             style="margin-top:5px;max-height:70px;max-width: 200px;">
                                    </div>
                                </div>
                                <hr data-am-widget="divider" class="am-divider am-divider-dashed"/>

                                <div>
                                    <img src="" id="img_show" style="max-height: 70px;">
                                </div>
                            </div>
                            <h4 class="tit_normal">
                                手机号码：
                            </h4>
                            <div class="listwraps elect-regions">
                                <div class="inputbg">
                                    <label class="labelbox">
                                        <input type="text" id="mobile" placeholder="请输入手机号码">
                                    </label>
                                </div>
                            </div>
                            <h4 class="tit_normal">
                                性别：
                            </h4>
                            <div class="listwraps elect-regions">
                                <div class="inputbg">
                                    <label class="labelbox">
                                        <input type="text" id="sex" placeholder="请输入性别: 1代表男；0代表女">
                                    </label>
                                </div>
                            </div>
                            <h4 class="tit_normal">
                                生日：
                            </h4>
                            <div class="listwraps elect-regions">
                                <div class="inputbg">
                                    <label class="labelbox">
                                        <input type="text" class="datepicker" id="birthday" placeholder="格式yy-mm-dd">
                                        <span class="input-group-addon"><i class="icon-calendar bigger-110"></i></span>
                                    </label>
                                </div>
                            </div>
                            <h4 class="tit_normal">
                                邮箱：
                            </h4>
                            <div class="listwraps elect-regions">
                                <div class="inputbg">
                                    <label class="labelbox">
                                        <input type="text" id="email" placeholder="请输入邮箱">
                                    </label>
                                </div>
                            </div>
                            <h4 class="tit_normal">
                                密码：
                            </h4>
                            <div class="listwraps elect-regions">
                                <div class="inputbg">
                                    <label class="labelbox">
                                        <input type="password" id="password" placeholder="请输入密码">
                                    </label>
                                </div>
                            </div>
                            <h4 class="tit_normal">
                                确认密码：
                            </h4>
                            <div class="listwraps elect-regions">
                                <div class="inputbg">
                                    <label class="labelbox">
                                        <input type="password" id="check_password" placeholder="请再次输入密码">
                                    </label>
                                </div>
                            </div>

                            <div class="fixed_bot mar_phone_dis1">
                                <input class="btn332 btn_reg_1 submit" data-to="phone-step2" type="submit"
                                       value="立即注册">
                                <p class="msg">
                                    注册帐号即表示您同意并愿意遵守长乐美食城 <a href="http://www.miui.com/res/doc/eula/cn.html"
                                                            class="inspect_link agreement_link" title="用户协议"
                                                            target="_blank">用户协议</a>和<a
                                        href="http://www.miui.com/res/doc/privacy/cn.html"
                                        class="inspect_link privacy_link" title=" 隐私政策 " target="_blank"> 隐私政策 </a>
                                </p>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<div class="n-footer">
    <div class="nf-link-area clearfix">
        <ul class="lang-select-list">
            <li><a class="lang-select-li current" href="javascript:void(0)" data-lang="zh_CN">简体</a>|</li>
            <li><a class="lang-select-li" href="javascript:void(0)" data-lang="zh_TW">繁体</a>|</li>
            <li><a class="lang-select-li" href="javascript:void(0)" data-lang="en">English</a></li>
            |
            <li><a class="a_critical" href="https://static.account.xiaomi.com/html/faq/faqList.html"
                   target="_blank"><em></em>常见问题</a></li>
        </ul>
    </div>
    <p class="nf-intro">
        <span>武汉长乐未央网络科技有限公司版权所有<br>
            <img src="https://account.xiaomi.com/static/res/9204d06/account-static/respassport/acc-2014/img/ghs.png">
        </span>鄂公网安备1234567890011号-鄂ICP证666888号</span>
    </p>
</div>

<script src="__PUBLIC__/vendor/assets/js/jquery.min.js"></script>
<script src="__PUBLIC__/vendor/bootstrapextend/js/bootstrap.extend.js"></script>
<script>
    $(function () {
        $('.submit').click(function () {
            var info = {
                nickname: $("#nickname").val(),
                customer_no: $("#customer_no").val(),
                email: $("#email").val(),
                mobile: $("#mobile").val(),
                thumb: $("#thumb").val(),
                sex: $("#sex").val(),
                birthday: $("#birthday").val(),
                password: $("#password").val(),
                check_password: $("#check_password").val()
            };
//            console.log(info);return false;

            if (info.nickname == "" || info.nickname.length < 3) {
                alert('用户名长度最低3位');
                return false;
            }

            var re = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/;
            if (!re.test(info.email)) {
                alert('邮箱格式不正确');
                return false;
            }

            if (!(/^1(3|4|5|7|8)\d{9}$/.test(info.mobile))) {
                alert('手机号格式不正确');
                return false;
            }

            if (info.password.length < 6) {
                alert('密码最低6位');
                return false;
            }

            if (info.check_password.length < 6) {
                alert('确认密码最低6位');
                return false;
            }

            if (info.password != info.check_password) {
                alert('两次密码输入不一样');
                return false;
            }

            $.post("{{:U('register')}}", info, function (data) {
                if (data.status == 1) {
                    alert(data.msg);
                    location.href = "{{:U('Customer/login')}}";
                } else {
                    alert(data.msg);
                    return false;
                }
            });
            return false;
        });

        //给上传图片按钮绑定事件
        $('.new_thumb').click(function () {
            $("#file_upload_1-button").click();
        });

        //上传单张
        $('#upload_one').Huploadify({
            uploader: '{{:U("Admin/Uploadfile/upload")}}',
            fileTypeExts: '*.gif;*.jpg;*.jpeg;*.png;*.bmp',
            //fileSizeLimit:{:C('UPLOAD_IMAGE_SIZE')}*1024,
            buttonText: '上 传 图 片',
            onUploadComplete: function (file, data) {
                data = $.parseJSON(data);
                $('#view_one img').attr('src', data.real_path);
                $('#view_one input').attr('value', data.real_path);
            }
        });
    })
</script>

